package main
import (
	"fmt"
	"math"
)

// 定义接口
type Shape interface {
    area() float64
	perimeter() float64
}

// 定义结构体
type Circle struct{
	radius float64
}

// Circle实现接口
func (c Circle) area() float64{
	return math.Pi * c.radius * c.radius
}

func (c Circle) perimeter() float64{
	return 2*math.Pi*c.radius
}

// 定义结构体
type Rectangle struct{
	width, height float64
}

// Rectangle实现接口
func (r Rectangle) area() float64{
	return r.width * r.height
}

func (r Rectangle) perimeter() float64{
	return 2*(r.width + r.height)
}

func main(){
	circle := Circle{radius: 5.0}
	rectangle := Rectangle{width: 4.0, height: 2.0}

	fmt.Println("Circle area:", circle.area())
	fmt.Println("Rectangle area:", rectangle.area())
	fmt.Println("Circle perimeter:", circle.perimeter())
	fmt.Println("Rectangle perimeter:", rectangle.perimeter())
}

/* -->
Circle area: 78.53981633974483
Rectangle area: 8
Circle perimeter: 31.41592653589793
Rectangle perimeter: 12

*/